﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RRs1090haigla3Request", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RRs1090haigla3Request))]
    public class RRs1090haigla3RequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRRs1090haigla3Request clazz;
        
        public RRs1090haigla3RequestSerializer(IRRs1090haigla3Request clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("ikirje_tyyp");
            if (clazz.IkirjeTyyp!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IkirjeTyyp))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IkirjeTyyp");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("ctellimusnr");
            if (clazz.Ctellimusnr!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Ctellimusnr))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Ctellimusnr");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("claps_kood");
            if (clazz.ClapsKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ClapsKood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : ClapsKood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("claps_saeg");
            if (clazz.ClapsSaeg!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ClapsSaeg))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : ClapsSaeg");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("cema_ikood");
            if (clazz.CemaIkood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.CemaIkood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : CemaIkood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("cema_pere");
            if (clazz.CemaPere!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.CemaPere))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : CemaPere");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("cema_ees");
            if (clazz.CemaEes!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.CemaEes))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : CemaEes");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("iriik");
            if (clazz.Iriik!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Iriik))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Iriik");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("imaak");
            if (clazz.Imaak!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Imaak))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Imaak");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("ivald");
            if (clazz.Ivald!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Ivald))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Ivald");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("iasula");
            if (clazz.Iasula!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Iasula))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Iasula");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("caadress");
            if (clazz.Caadress!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Caadress))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Caadress");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("ctoend");
            if (clazz.Ctoend!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Ctoend))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Ctoend");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("cttoend_kpv");
            if (clazz.CttoendKpv!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.CttoendKpv))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : CttoendKpv");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="ikirje_tyyp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1090haigla3Request>ikirje_tyyp");
                }
                clazz.IkirjeTyyp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ikirje_tyyp")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1090haigla3Request>ikirje_tyyp", Reader.LocalName);
            }
            if (Reader.LocalName=="ctellimusnr") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1090haigla3Request>ctellimusnr");
                }
                clazz.Ctellimusnr = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ctellimusnr")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1090haigla3Request>ctellimusnr", Reader.LocalName);
            }
            if (Reader.LocalName=="claps_kood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1090haigla3Request>claps_kood");
                }
                clazz.ClapsKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("claps_kood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1090haigla3Request>claps_kood", Reader.LocalName);
            }
            if (Reader.LocalName=="claps_saeg") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1090haigla3Request>claps_saeg");
                }
                clazz.ClapsSaeg = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("claps_saeg")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1090haigla3Request>claps_saeg", Reader.LocalName);
            }
            if (Reader.LocalName=="cema_ikood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1090haigla3Request>cema_ikood");
                }
                clazz.CemaIkood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("cema_ikood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1090haigla3Request>cema_ikood", Reader.LocalName);
            }
            if (Reader.LocalName=="cema_pere") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1090haigla3Request>cema_pere");
                }
                clazz.CemaPere = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("cema_pere")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1090haigla3Request>cema_pere", Reader.LocalName);
            }
            if (Reader.LocalName=="cema_ees") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1090haigla3Request>cema_ees");
                }
                clazz.CemaEes = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("cema_ees")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1090haigla3Request>cema_ees", Reader.LocalName);
            }
            if (Reader.LocalName=="iriik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1090haigla3Request>iriik");
                }
                clazz.Iriik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("iriik")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1090haigla3Request>iriik", Reader.LocalName);
            }
            if (Reader.LocalName=="imaak") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1090haigla3Request>imaak");
                }
                clazz.Imaak = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("imaak")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1090haigla3Request>imaak", Reader.LocalName);
            }
            if (Reader.LocalName=="ivald") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1090haigla3Request>ivald");
                }
                clazz.Ivald = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ivald")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1090haigla3Request>ivald", Reader.LocalName);
            }
            if (Reader.LocalName=="iasula") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1090haigla3Request>iasula");
                }
                clazz.Iasula = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("iasula")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1090haigla3Request>iasula", Reader.LocalName);
            }
            if (Reader.LocalName=="caadress") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1090haigla3Request>caadress");
                }
                clazz.Caadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("caadress")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1090haigla3Request>caadress", Reader.LocalName);
            }
            if (Reader.LocalName=="ctoend") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1090haigla3Request>ctoend");
                }
                clazz.Ctoend = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ctoend")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1090haigla3Request>ctoend", Reader.LocalName);
            }
            if (Reader.LocalName=="cttoend_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1090haigla3Request>cttoend_kpv");
                }
                clazz.CttoendKpv = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("cttoend_kpv")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1090haigla3Request>cttoend_kpv", Reader.LocalName);
            }
        }
    }
}
